﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BGM_Approval_Edit_Expense.aspx.cs" Inherits="KPIS.GERP.GBMS.APP_UI.BGM_Approval_Edit_Expense" %>

<%@ Register src="../Controls/Combo/YearCombo.ascx" tagname="year" tagprefix="uc8" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head id="Head1" runat="server">
<title><asp:Literal runat="Server" id="litTitle"/></title>
<link rel="Stylesheet" href="../../Styles/StyleSheet.css" type="text/css">
</head>
	<body>
	    <form id="form1" method="post" runat="server">
	    
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None"  > 
        </telerik:RadAjaxLoadingPanel>
        
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnEditExpense">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="panel_project" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="panel_expense" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnEditProject">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="panel_project" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="panel_expense" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

		
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">

                function openProjectDetails(id) {

                    closeRadWindow();

                    var hid = document.getElementById("<%= hdfHeaderID.ClientID %>").value;
                    var type = document.getElementById("<%= hdType.ClientID %>").value;

                    radopen("BGM_Project.aspx?id=" + id + "&header=" + hid + "&type=ap", "ProjectDtls");

                    return false;
                }

                function closeRadWindow(sender, args) {
                    return false;
                }

                function isNumberKey(event) 
                {
                 var charCode = (event.which) ? event.which : event.keyCode
                 if(charCode > 31 && (charCode < 48 || charCode > 57)){
                     return false;
                  }
                 return true;
                }

                var cancelDropDownClosing = false;

                function onTextChange(sender) {
                    if (sender.get_value() == "") {
                        sender.set_text("");
                    }
                } 
                function StopPropagation(e) {
                    e.cancelBubble = true;
                    if (e.stopPropagation) {
                        e.stopPropagation();
                    }
                }

                function OnClientDropDownClosingHandler(sender, e) {
                    e.set_cancel(cancelDropDownClosing);
                }

        </script>
    </telerik:RadCodeBlock>
    
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"  
        ReloadOnShow="true" runat="server" Skin="WebBlue" Modal="true" KeepInScreenBounds="false" Style="z-index: 7001">
        <Windows>
            <telerik:RadWindow ID="ProjectDtls" runat="server" Width="860px" Height="450px" Behaviors="Reload, Close" OnClientClose="closeRadWindow">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>  
       
    <div style="font-family: 'Segoe UI'; font-size: 13px; background-color: #E3F5FF;">            
        <asp:Panel ID="panelHeader" runat="server">
            <div class="header-grid">
                <table cellpadding="0" cellspacing="0" class="defaultTable">
                    <tr>
                        <td align="left" valign="top" width="50%" style="padding: 5px; font-family: 'Segoe UI'; font-size: 13px;">
                            <ul class="treeview-list">
                                <li class="treeview-item" style="border: none">
                                    <asp:LinkButton ID="btnEditProject" runat="server" CssClass="LinkButton" onclick="btnEditProject_Click"><img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/table.gif" />&nbsp;&nbsp;แสดงรายชื่อโครงการ</asp:LinkButton>
                                </li>
                                <li class="treeview-item">
                                    <asp:LinkButton ID="btnEditExpense" runat="server" CssClass="LinkButton" OnClick="btnEditExpense_Click"><img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/table.gif" />&nbsp;&nbsp;แสดงรายละเอียดค่าใช้จ่าย</asp:LinkButton>
                                </li>
                                <li class="treeview-item">
                                    <asp:LinkButton ID="btnAddProject" runat="server" CssClass="LinkButton"><img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;เพิ่มโครงการใหม่</asp:LinkButton>
                                </li>
                                <li class="treeview-item">
                                    <asp:LinkButton ID="btnSave" runat="server" CssClass="LinkButton" 
                                        onclick="btnSave_Click"><img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;บันทึกข้อมูล</asp:LinkButton>
                                </li>
                            </ul>
                        </td>
                    </tr>                
                </table>
            </div>
         </asp:Panel>    
            <asp:Panel ID="panel_Item1" runat="server" Height="410px" CssClass="defaultFont" ScrollBars="Auto">
                <asp:Label ID="lblStrategyID" runat="server" Visible="false"></asp:Label>                                            
                <asp:Label ID="lbSourceID" runat="server" Visible="false"></asp:Label>
                <asp:Label ID="lblHeaderID" runat="server" Visible="false"></asp:Label>
                <asp:HiddenField ID="hdType" runat="server"></asp:HiddenField>
                <asp:HiddenField ID="hdfHeaderID" runat="server" ></asp:HiddenField>
                <table cellpadding="0" cellspacing="0" style="width: 98%; font-family: 'Segoe UI'; font-size: 13px;">
                    <tr>
                        <td align="center">
                            <table cellpadding="0" cellspacing="0" class="defaultTable">
                                <tr>
                                    <td valign="top" style="padding-left:20px; padding-top:20px;">
                                        <asp:Panel ID="panel_project" runat="server" CssClass="defaultFont" >
                                            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridProject" runat="server"
                                                AutoGenerateColumns="False" OnItemCommand="gridProject_ItemCommand"
                                                GridLines="None" MasterTableView-GridLines="None" ClientSettings-EnablePostBackOnRowClick="true"
                                                Width="100%">
                                                <mastertableview ShowFooter="true" ShowGroupFooter="true" NoMasterRecordsText="... ไม่มีข้อมูล ..." commanditemdisplay="none" width="100%" GroupLoadMode="Client">                                                           
                                                <Columns>
                                                    <telerik:GridTemplateColumn AllowFiltering="false" visible="true">
                                                        <HeaderStyle Width="23px"></HeaderStyle>
                                                        <ItemTemplate>
                                                            <asp:ImageButton ID="CancelControl" BorderWidth="0px" ImageUrl="../Image/Grid/Cancel.gif" CommandName="CancelClick"
                                                                AlternateText="ยกเลิกโครงการ" Style="float: right; cursor: pointer;" runat="server">
                                                            </asp:ImageButton>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridBoundColumn DataField="bgm_project_name"
                                                        FooterText="รวมทั้งหมด :"
                                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                                        HeaderText="โครงการ" ItemStyle-HorizontalAlign="Left" 
                                                        UniqueName="bgm_project_name" >
                                                        <HeaderStyle HorizontalAlign="Center" />
                                                        <FooterStyle HorizontalAlign="Center" Font-Bold="true" />
                                                        <ItemStyle HorizontalAlign="Left" />
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridTemplateColumn HeaderText="CtrlSeq" AllowFiltering="false" visible="false" UniqueName="CtrlSeq">
                                                        <ItemTemplate>
                                                            <asp:Label  ID="lbCtrlSeq" runat="server" text='<%# Eval("bgm_project_ctrl_seq") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn HeaderText="ProjSeq" AllowFiltering="false" visible="false" UniqueName="ProjSeq">
                                                        <ItemTemplate>
                                                            <asp:Label  ID="lbProjSeq" runat="server" text='<%# Eval("bgm_project_seq") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridBoundColumn DataField="total_amount"
                                                        Aggregate="Sum"
                                                        DataFormatString="{0:#,##0.00}"
                                                        HeaderStyle-HorizontalAlign="Center"
                                                        HeaderText="เสนอขอ"
                                                        UniqueName="total_amount" Visible="true">
                                                        <HeaderStyle HorizontalAlign="Center" Width="100px"/>
                                                        <FooterStyle HorizontalAlign="Right" Font-Bold="true" />
                                                        <ItemStyle HorizontalAlign="Right" />
                                                    </telerik:GridBoundColumn>                                                    
                                                    <telerik:GridTemplateColumn HeaderText="delFlag" AllowFiltering="false" visible="false" UniqueName="delFlag">
                                                        <HeaderStyle Width="100px"></HeaderStyle>
                                                        <ItemTemplate>
                                                            <asp:Label  ID="lbFlag" runat="server" text="0"></asp:Label>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn HeaderText="ผ่านการพิจารณา" AllowFiltering="false" visible="true" UniqueName="approve_amount">
                                                        <HeaderStyle Width="100px"></HeaderStyle>
                                                        <ItemTemplate>
                                                            <telerik:RadNumericTextBox  ID="txtApproveAmount" runat="server" Width="100px" text='<%# Eval("approve_amount") %>'>
                                                            </telerik:RadNumericTextBox>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn AllowFiltering="false" visible="true">
                                                        <HeaderStyle Width="23px"></HeaderStyle>
                                                        <ItemTemplate>
                                                            <asp:ImageButton ID="DetailControl" BorderWidth="0px" ImageUrl="../Image/Grid/Magnifier.gif" OnClientClick='<%# string.Format("return openProjectDetails(\"{0}\");", Eval("bgm_project_seq")) %>'
                                                                AlternateText="แสดงรายละเอียด" Style="float: right; cursor: pointer;" runat="server">
                                                            </asp:ImageButton>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                </Columns>
                                                <groupbyexpressions>
                                                    <telerik:GridGroupByExpression>
                                                        <groupbyfields>
                                                            <telerik:GridGroupByField FieldName="job_site_seq" HeaderText="หน่วยงาน" />
                                                        </groupbyfields>
                                                        <selectfields>
                                                            <telerik:GridGroupByField FieldName="job_site_name" HeaderText="&nbsp;" HeaderValueSeparator="" />
                                                        </selectfields>
                                                    </telerik:GridGroupByExpression>
                                                </groupbyexpressions>
                                                </mastertableview>
                                                <clientsettings>
                                                    <clientevents /><selecting allowrowselect="True" />
                                                </clientsettings>
                                            </telerik:RadGrid>
                                        </asp:Panel>
                                        <asp:Panel ID="panel_expense" runat="server" CssClass="defaultFont" Visible="false">
                                            <br />
                                            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridExpense" runat="server" AllowFilteringByColumn="True" Font-Names="Segoe UI" Font-Size="13px"
                                                AllowMultiRowSelection="True" AutoGenerateColumns="False"
                                                GridLines="None" MasterTableView-GridLines="None" Width="100%">
                                                <mastertableview commanditemdisplay="None" grouploadmode="Client" width="100%" NoDetailRecordsText="... ไม่มีข้อมูล ...">
                                                       <groupbyexpressions>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_grp_seq" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_grp_name" HeaderText="งบรายจ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_seq_3" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_name_3" HeaderText="หมวดค่าใช้จ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_seq_2" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_name_2" HeaderText="รายการรายจ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_seq_1" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_name_1" HeaderText="รายการรายจ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                        </groupbyexpressions>
                                                        <Columns>
                                                            <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                                                FooterText="รวมทั้งหมด : "
                                                                CurrentFilterFunction="Contains" DataField="text" 
                                                                FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                                                HeaderText="ค่าใช้จ่าย" ShowFilterIcon="false" UniqueName="text">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                <FooterStyle HorizontalAlign="Center" Font-Bold="true" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridTemplateColumn visible="false"
                                                                HeaderStyle-HorizontalAlign="Center" HeaderText="รหัสค่าใช้จ่าย" ItemStyle-HorizontalAlign="Left"> 
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lbExpSeq" runat="server" Text='<%# Eval("value") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                            </telerik:GridTemplateColumn> 
                                                            <telerik:GridBoundColumn DataField="total_amount" Aggregate="Sum"
                                                                DataFormatString="{0:#,##0.00}"
                                                                HeaderStyle-HorizontalAlign="Center"  AllowFiltering="false"
                                                                HeaderText="เสนอขอ(บาท)" UniqueName="total_amount">
                                                                <HeaderStyle HorizontalAlign="Center" Width="20%" />
                                                                <ItemStyle HorizontalAlign="Right" />
                                                                <FooterStyle HorizontalAlign="Center" Font-Bold="true" />                                                                    
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridTemplateColumn HeaderStyle-Width="20%" ShowFilterIcon="false" AllowFiltering="false" UniqueName="approve_amount"
                                                                HeaderStyle-HorizontalAlign="Center" HeaderText="ผ่านการพิจารณา(บาท)" ItemStyle-HorizontalAlign="Left"> 
                                                                <ItemTemplate>
                                                                    <telerik:RadNumericTextBox ID="txtApproveAmount" runat="server" Width="100%"  Text='<%# Eval("approve_amount") %>'></telerik:RadNumericTextBox>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                            </telerik:GridTemplateColumn> 
<%--                                                            <telerik:GridTemplateColumn visible="false"
                                                                HeaderStyle-HorizontalAlign="Center" HeaderText="รหัสค่าใช้จ่าย" ItemStyle-HorizontalAlign="Left"> 
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lbReqExpSeq" runat="server" Text='<%# Eval("bgm_req_exp_seq") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                            </telerik:GridTemplateColumn> 
--%>                                                        </Columns>
                                                    </mastertableview>
                                                <clientsettings enablerowhoverstyle="true">
                                                    <clientevents />
                                                    <selecting allowrowselect="True" />
                                                </clientsettings>
                                            </telerik:RadGrid>
                                        </asp:Panel>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
		    </div>     
		</form>
	</body>
</html>
